/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * File Name          : freertos.c
  * Description        : Code for freertos applications
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2025 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
  */
/* USER CODE END Header */

/* Includes ------------------------------------------------------------------*/
#include "FreeRTOS.h"
#include "task.h"
#include "main.h"
#include "cmsis_os.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */

/* USER CODE END PTD */

/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */

/* USER CODE END PD */

/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */

/* USER CODE END PM */

/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN Variables */

/* USER CODE END Variables */
/* Definitions for Task_Recorder */
osThreadId_t Task_RecorderHandle;
const osThreadAttr_t Task_Recorder_attributes = {
  .name = "Task_Recorder",
  .stack_size = 1024 * 4,
  .priority = (osPriority_t) osPriorityBelowNormal7,
};
/* Definitions for Task_RV1ADC_Vol */
osThreadId_t Task_RV1ADC_VolHandle;
const osThreadAttr_t Task_RV1ADC_Vol_attributes = {
  .name = "Task_RV1ADC_Vol",
  .stack_size = 512 * 4,
  .priority = (osPriority_t) osPriorityNormal,
};
/* Definitions for Task_AudioPlay */
osThreadId_t Task_AudioPlayHandle;
const osThreadAttr_t Task_AudioPlay_attributes = {
  .name = "Task_AudioPlay",
  .stack_size = 1024 * 4,
  .priority = (osPriority_t) osPriorityNormal,
};
/* Definitions for Task_ESP8266 */
osThreadId_t Task_ESP8266Handle;
const osThreadAttr_t Task_ESP8266_attributes = {
  .name = "Task_ESP8266",
  .stack_size = 512 * 4,
  .priority = (osPriority_t) osPriorityNormal,
};
/* Definitions for Task_ANS */
osThreadId_t Task_ANSHandle;
const osThreadAttr_t Task_ANS_attributes = {
  .name = "Task_ANS",
  .stack_size = 2048 * 4,
  .priority = (osPriority_t) osPriorityNormal,
};
/* Definitions for Queue_KeyNumbers */
osMessageQueueId_t Queue_KeyNumbersHandle;
const osMessageQueueAttr_t Queue_KeyNumbers_attributes = {
  .name = "Queue_KeyNumbers"
};
/* Definitions for Queue_WavWitchBuff */
osMessageQueueId_t Queue_WavWitchBuffHandle;
const osMessageQueueAttr_t Queue_WavWitchBuff_attributes = {
  .name = "Queue_WavWitchBuff"
};
/* Definitions for BinSem_wavTransferEnd */
osSemaphoreId_t BinSem_wavTransferEndHandle;
const osSemaphoreAttr_t BinSem_wavTransferEnd_attributes = {
  .name = "BinSem_wavTransferEnd"
};
/* Definitions for BimSem_usart3_get */
osSemaphoreId_t BimSem_usart3_getHandle;
const osSemaphoreAttr_t BimSem_usart3_get_attributes = {
  .name = "BimSem_usart3_get"
};
/* Definitions for BinSem_iircoe_change */
osSemaphoreId_t BinSem_iircoe_changeHandle;
const osSemaphoreAttr_t BinSem_iircoe_change_attributes = {
  .name = "BinSem_iircoe_change"
};

/* Private function prototypes -----------------------------------------------*/
/* USER CODE BEGIN FunctionPrototypes */

/* USER CODE END FunctionPrototypes */

void AppTask_Recorder(void *argument);
void AppTask_RV1ADC_Vol(void *argument);
void AppTask_AudioPlay(void *argument);
void AppTask_ESP8266(void *argument);
void AppTask_ANS(void *argument);

void MX_FREERTOS_Init(void); /* (MISRA C 2004 rule 8.1) */

/**
  * @brief  FreeRTOS initialization
  * @param  None
  * @retval None
  */
void MX_FREERTOS_Init(void) {
  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* USER CODE BEGIN RTOS_MUTEX */
  /* add mutexes, ... */
  /* USER CODE END RTOS_MUTEX */

  /* Create the semaphores(s) */
  /* creation of BinSem_wavTransferEnd */
  BinSem_wavTransferEndHandle = osSemaphoreNew(1, 1, &BinSem_wavTransferEnd_attributes);

  /* creation of BimSem_usart3_get */
  BimSem_usart3_getHandle = osSemaphoreNew(1, 1, &BimSem_usart3_get_attributes);

  /* creation of BinSem_iircoe_change */
  BinSem_iircoe_changeHandle = osSemaphoreNew(1, 1, &BinSem_iircoe_change_attributes);

  /* USER CODE BEGIN RTOS_SEMAPHORES */
  /* add semaphores, ... */
  /* USER CODE END RTOS_SEMAPHORES */

  /* USER CODE BEGIN RTOS_TIMERS */
  /* start timers, add new ones, ... */
  /* USER CODE END RTOS_TIMERS */

  /* Create the queue(s) */
  /* creation of Queue_KeyNumbers */
  Queue_KeyNumbersHandle = osMessageQueueNew (1, sizeof(uint8_t), &Queue_KeyNumbers_attributes);

  /* creation of Queue_WavWitchBuff */
  Queue_WavWitchBuffHandle = osMessageQueueNew (1, sizeof(uint8_t), &Queue_WavWitchBuff_attributes);

  /* USER CODE BEGIN RTOS_QUEUES */
  /* add queues, ... */
  /* USER CODE END RTOS_QUEUES */

  /* Create the thread(s) */
  /* creation of Task_Recorder */
  Task_RecorderHandle = osThreadNew(AppTask_Recorder, NULL, &Task_Recorder_attributes);

  /* creation of Task_RV1ADC_Vol */
  Task_RV1ADC_VolHandle = osThreadNew(AppTask_RV1ADC_Vol, NULL, &Task_RV1ADC_Vol_attributes);

  /* creation of Task_AudioPlay */
  Task_AudioPlayHandle = osThreadNew(AppTask_AudioPlay, NULL, &Task_AudioPlay_attributes);

  /* creation of Task_ESP8266 */
  Task_ESP8266Handle = osThreadNew(AppTask_ESP8266, NULL, &Task_ESP8266_attributes);

  /* creation of Task_ANS */
  Task_ANSHandle = osThreadNew(AppTask_ANS, NULL, &Task_ANS_attributes);

  /* USER CODE BEGIN RTOS_THREADS */
  /* add threads, ... */
  /* USER CODE END RTOS_THREADS */

  /* USER CODE BEGIN RTOS_EVENTS */
  /* add events, ... */
  /* USER CODE END RTOS_EVENTS */

}

/* USER CODE BEGIN Header_AppTask_Recorder */
/**
  * @brief  Function implementing the Task_Recorder thread.
  * @param  argument: Not used
  * @retval None
  */
/* USER CODE END Header_AppTask_Recorder */
__weak void AppTask_Recorder(void *argument)
{
  /* USER CODE BEGIN AppTask_Recorder */
  /* Infinite loop */
  for(;;)
  {
    osDelay(1);
  }
  /* USER CODE END AppTask_Recorder */
}

/* USER CODE BEGIN Header_AppTask_RV1ADC_Vol */
/**
* @brief Function implementing the Task_RV1ADC_Vol thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_AppTask_RV1ADC_Vol */
__weak void AppTask_RV1ADC_Vol(void *argument)
{
  /* USER CODE BEGIN AppTask_RV1ADC_Vol */
  /* Infinite loop */
  for(;;)
  {
    osDelay(1);
  }
  /* USER CODE END AppTask_RV1ADC_Vol */
}

/* USER CODE BEGIN Header_AppTask_AudioPlay */
/**
* @brief Function implementing the Task_AudioPlay thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_AppTask_AudioPlay */
__weak void AppTask_AudioPlay(void *argument)
{
  /* USER CODE BEGIN AppTask_AudioPlay */
  /* Infinite loop */
  for(;;)
  {
    osDelay(1);
  }
  /* USER CODE END AppTask_AudioPlay */
}

/* USER CODE BEGIN Header_AppTask_ESP8266 */
/**
* @brief Function implementing the Task_ESP8266 thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_AppTask_ESP8266 */
__weak void AppTask_ESP8266(void *argument)
{
  /* USER CODE BEGIN AppTask_ESP8266 */
  /* Infinite loop */
  for(;;)
  {
    osDelay(1);
  }
  /* USER CODE END AppTask_ESP8266 */
}

/* USER CODE BEGIN Header_AppTask_ANS */
/**
* @brief Function implementing the Task_ANS thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_AppTask_ANS */
__weak void AppTask_ANS(void *argument)
{
  /* USER CODE BEGIN AppTask_ANS */
  /* Infinite loop */
  for(;;)
  {
    osDelay(1);
  }
  /* USER CODE END AppTask_ANS */
}

/* Private application code --------------------------------------------------*/
/* USER CODE BEGIN Application */

/* USER CODE END Application */

